package eli.turchinsky.software.agame.enteties;

import eli.turchinsky.software.agame.R;
import eli.turchinsky.software.agame.hood.Vector2;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class Man extends GameEntety {
	private static final Man instance = new Man();	 
	private Man() {
		super(0,0,30,30,null);
	}	    	
	public static Man getInstance() {
		return instance;
	}
	public void init(float x,float y,Resources resources){
		_position.set(x, y);
		_resources=resources;
		Bitmap bMap = BitmapFactory.decodeResource(resources,R.drawable.robot);
		_sprite.Initialize(bMap, (int)_width,(int) _height, 10, 3);
	}	
	public void left(){
		int onStarSpeed=20;
		if(getTouchingStar()!=null)
		{
			Vector2 ad=(getCenterPos().angleDif(getTouchingStar().getCenterPos()));
			_velocity = ad.getOrthogonal().mul(5);
		}
		setMoving(true);
	}
	public void jump(){	
		float _jumpPop=80;
		float _jumpVel=15;
		if (getTouchingStar() != null)
		{
			Vector2 ad=(getCenterPos().angleDif(getTouchingStar().getCenterPos()));
			getCenterPos().add( ad.dot( new Vector2(_jumpPop, _jumpPop)));
			_velocity.add((ad .dot(new Vector2(_jumpVel, _jumpVel))));
			//IsMoving = true;
			//Velocity += AngleDifVector * 20;
			//Console.WriteLine(AngleDifVector);
			//prevTouchingStar = TouchingStar;
			//SoundManager.Instance.PlayEffect("jump");
		}
	}	

}
